<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:jsf="http://xmlns.jcp.org/jsf"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:o="http://omnifaces.org/ui">

    <div>
        <p:panel header="Inicio" style="border:none;">
            <!-- contenido WEB -->
            <div align="center">
                <h:form>
                    <div class="dynaFormLabel">  
                        <p:outputLabel value="Año de socios"/>  
                    </div>
                    <p:selectOneMenu value="#{reportBean.yearReport}">
                        <f:selectItem itemLabel="Selecione Año" noSelectionOption="true" />
                        <f:selectItems value="#{businessAssociateBean.listApertureAssociate}"
                                       var="aper" itemLabel="#{aper.year}" itemValue="#{aper.year}" />
                        <p:ajax event="change" update=":category" 
                                listener="#{reportBean.searchResult}" />
                    </p:selectOneMenu>
                </h:form>
            </div>
  
                <p:lineChart id="category" legendPosition="e" 
                             value="#{reportBean.linearModel}"
                             widgetVar="chart" 
                             title="Socios del año" minY="0" zoom="true"  
                             style="height:300px;margin-top:20px" >
                    <p:effect type="slide" event="load" >  
                    </p:effect> 
                </p:lineChart>
     
            <h:form>
                <p:commandButton type="button" value="Export" 
                                 icon="ui-icon-extlink" onclick="exportChart()" />
            </h:form>
        </p:panel>
        <script >
            function exportChart() {
                //export image  
                $('#output').empty().append(PF('chart').exportAsImage());

                //show the dialog  
                PF('dlg').show();
            }
        </script>
    </div>

    <p:dialog widgetVar="dlg" showEffect="fade" appendTo="@(body)"
              modal="true" header="Chart as an Image">  
        <p:outputPanel id="output" layout="block" style="width:500px;height:300px"/>  
    </p:dialog>
</ui:composition>

